package cn.wn.web;

import cn.wn.model.ResultInfo;
import cn.wn.pojo.Role;
import cn.wn.pojo.User;
import cn.wn.service.RoleService;
import cn.wn.service.UserService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("role")
@Api(tags = "角色管理")
@Slf4j
public class RoleController {
    @Autowired
    private RoleService roleService;

    // 访问角色列表需要权限：role:list
    @GetMapping("/page/{pageNum}/{pageSize}")
    @ApiOperation(value = "查询全部")
    @RequiresPermissions("role:list")   // shiro 权限校验注解
    public ResultInfo<PageInfo> findByPage(
            @PathVariable("pageNum") Integer pageNum,
            @PathVariable("pageSize") Integer pageSize){
        PageInfo<Role> pageInfo = roleService.findByPage(pageNum,pageSize);
        return ResultInfo.ok(pageInfo);
    }

}
